ActiveReports 9
Custom Resource Locator
Show AllShow All
Hide AllHide All

Page reports can get resources from your file system using file paths, but sometimes resources are preserved in very specific sources, such as a database. With page reports, you can create a custom resource locator to read any resources that might be required by your reports from any location. This walkthrough is based on the Custom Resource Locator sample and illustrates how to load pictures from the user's My Pictures directory.

This walkthrough is split into the following procedures:

Note: Although this walkthrough uses Page reports, but this can be implemented using RDL reports also.

When you complete this walkthrough you get a layout that looks similar to the following at runtime.

To add an ActiveReports to the Visual Studio project

  1. Create a new Visual Studio Windows Forms Application project.
  2. From the Project menu, select Add New Item.
  3. In the Add New Item dialog that appears, select ActiveReports 9 Page Report and in the Name field, rename the file as DemoReport.rdlx.
  4. Click the Add button to open a new fixed page report.

To create a layout for the report

  1. From the toolbox, drag an Image control onto the design surface and in the Properties window, set the following properties.
    Property Name Property Value
    Name Image1
    Location 0.1in, 0.1in
    Size 2.8in, 2.8in
    Value MyPictures:Penguins.jpg
  2. From the toolbox, drag another Image control onto the design surface and in the Properties window, set the following properties.
    Property Name Property Value
    Name Image2
    Location 3.1in, 0.1in
    Size 2.8in, 2.8in
    Value MyPictures:Desert.jpg
  3. In the Solution Explorer, select DemoReport.rdlx and in the Properties window, set Build Action to Embedded Resource.

To add the new MyPicturesLocator class

  1. In the Solution Explorer window, right-click on your project name and select Add and then New Item.
  2. In the Add New Item dialog that appears, select Class.
  3. Change the name of the class to MyPicturesLocator and click the Add button.
  4. Replace the existing code with the following code to the new class.

    To write the code in Visual Basic.NET

    To write the code in C#

To create the PreviewForm

  1. In the Solution Explorer, select the Form1 in the Design view and in the Properties window, set the properties as follows. 
    Property Name Property Value
    Name PreviewForm
    Text Preview Form
    Size 1015, 770
  2. From the Visual Studio toolbox, drag the Viewer control onto the PreviewForm and in the Properties window, set the following properties.
    Property Name Property Value
    Name reportPreview1
    Dock Fill
  3. Double-click the PreviewForm to create an instance for the Load event and add the following code.

    To write the code in Visual Basic.NET

    To write the code in C#

  4. Press F5 to run the project.
See Also

Concepts

Page Report Walkthroughs

Sample ReadMe Files

 

 


Copyright © 2014 GrapeCity, inc. All rights reserved

Support Forum